package com.kiku.reggie.common;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class SMSUtils1 {

    /**
     * 短信发送工具类
     *
     @param signName     签名
     @param templateCode 模板
     @param phoneNumbers 手机号
     @param param        验证码
     */
    public static void sendMessage(String signName, String templateCode, String phoneNumbers, String param) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI5tNztPeDutJtuKb6uGmM", "DSM9hZtyBAJ32h3vvUtSPsGLPRr6sq");
        IAcsClient client = new DefaultAcsClient(profile);

        SendSmsRequest request = new SendSmsRequest();
        request.setSysRegionId("cn-hangzhou");
        request.setPhoneNumbers(phoneNumbers);
        request.setSignName(signName);
        request.setTemplateCode(templateCode);
        request.setTemplateParam("{\"code\":\"" + param + "\"}");
        try {
            SendSmsResponse response = client.getAcsResponse(request);
            log.info("短信发送返回信息" + response.getMessage());
        } catch (ClientException e) {
            e.printStackTrace();
        }

    }
}
